﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;

namespace H_GAME
{
    public class Cls_Dog:Cls_Bio
    {
        //狗的动作
        ArrayList Z_Imgs = new ArrayList();


        #region 狗的动作行为
        public void Ini()
        {
            //初始参数设置
            Live = 500; //生命值
            Speed = 20; //行走速度
            Name = "阿猫阿狗"; //名字
            Destroyedval = 5;  //攻击力
            Imgpath = Application.StartupPath + "\\Pic\\Dog";
            Img = new Bitmap(Imgpath+"\\D1.png");
            Imgtype = "Z";
            Func = "L";
            Y = 600 - Img.Height;

            #region 素材设置
            Z_Imgs = new ArrayList();
            Z_Imgs.Add("D1.png");
            Z_Imgs.Add("D2.png");
            #endregion
        }

        /// <summary>
        /// 移动
        /// </summary>
        public void ImgMove()
        {
            if (Imgtype == "Z")
            {
                if (Func == "L")
                {
                    //左
                    X = X - Speed;
                }
                else if (Func == "R")
                {
                    //右
                    X = X + Speed;
                }
            }
        }

        /// <summary>
        /// 获取动作
        /// </summary>
        /// <param name="e"></param>
        public void GetImgAction(Graphics e)
        {
            if (Imgtype == "Z")
            {
                if (Imgindex < Z_Imgs.Count - 1)
                {
                    Imgindex++;
                }
                else
                {
                    Imgindex = 0;
                }
            }
            //else if (Imgtype == "S")
            //{
                 
            //}
            Img = new Bitmap(Imgpath + "\\" + Z_Imgs[Imgindex].ToString());
            if (Func == "R")
                Img.RotateFlip(RotateFlipType.Rotate180FlipY);
            e.DrawImage(Img,X,Y);
        }

         /// <summary>
        /// 自动操作 电脑智能
        /// </summary>
        public void DocAuto()
        {
            Random tn = new Random();
            int tempval = tn.Next(0, 500);
            if (tempval > 0 && tempval < 20)
            {
                 //左
               Func="L";
               Imgtype = "Z";
            }
            else if (tempval > 40 && tempval < 60)
            {
                 //右
                Func = "R";
                Imgtype = "Z";
            }
            else if (tempval > 60 && tempval < 65)
            {
                Imgtype = "S";
            }
        }


        #endregion

    }
}
